package com.hisense.ncc.datafix;

import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;

import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

public class WoYx001AttachDataFix {
	
	
//	[{
//		"billType": "market_collection",
//		"billGuid": "6f4dc456-4bb1-4400-4ff5-08d9cd69dd0b",
//		"minioUrl": ["2021/12/28/dcsatsd7671ea66be449118348efaca51fb5e7.pdf",
//			"2021/12/28/dcsatsd7671ea66be449118348efaca51fb5e7.pdf"
//		]
//	}]
	
	
	public static void main(String[] args) {
		
		
		try {
			List<String> readAllLines = Files.readAllLines(Paths.get("E:\\Users\\tangxqa\\Desktop\\预导入.txt"));
			
			RestTemplate restTemplate = new RestTemplate();
			
			for (String line : readAllLines) {
				String[] split = line.split(" ");
				String attachUrl = split[0];
				String guid = split[1];
				if (split.length < 3) {
					continue;
				}
				
				String billno = split[2];
				JSONObject body = new JSONObject();
				body.put("billType", "market_collection");
				JSONArray bodyArray = new JSONArray();
				body.put("billGuid", guid.toLowerCase());
				String[] minioUrls = {attachUrl};
				body.put("minioUrl", minioUrls);
				bodyArray.add(body);
				
				ResponseEntity<String> postForEntity = restTemplate.postForEntity("https://dcfinct.hisense.com/uapws/rest/sscrp/statement/minio/attachment", bodyArray, String.class);
				
				System.out.println(billno + " " + postForEntity.getBody());
			}
			
			
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		
		
		
		
	}

}
